package org.bdware.doip.core.doipMessage;

import org.apache.log4j.Logger;
import org.bdware.doip.core.utils.GlobalConfigurations;

import java.net.InetSocketAddress;

public class DoipMessage {

    public transient int requestID = 0;
    private transient int maxTransferUnit;
    private transient InetSocketAddress sender;
    private transient String recipientID = null;        //mainly user to encryption

    public MessageHeader header;
    public MessageBody body;
    public MessageCredential credential;

    public DoipMessage(String id, String opCode){
        header = new MessageHeader(id,opCode);
        body = new MessageBody();
        maxTransferUnit = GlobalConfigurations.defaultMsgMTU;
    }

    public DoipMessage(String id, String opCode, int flag){
        header = new MessageHeader(id,opCode,flag);
        body = new MessageBody();
        maxTransferUnit = GlobalConfigurations.defaultMsgMTU;
    }

    public boolean isRequest() {
        return header.isRequest();
    }

    public InetSocketAddress getSender() {
        return sender;
    }


    public void setSender(InetSocketAddress sender) {
        this.sender = sender;
    }

    public int getMTU() {return maxTransferUnit;}
    public void setMTU(int m){
        this.maxTransferUnit = m;
    }

    public String getRecipientID() {
        return recipientID;
    }

    public void setRecipientID(String recipientID) {
        this.recipientID = recipientID;
    }
}
